package com.learn.threadLocal;

/**
 * @author ln
 * @Description: ${todo}
 * @date 2020/12/26
 */
public class TestTwo {


    //    变量
    private String content;

    public  String getContent() {
        return content;
    }

    public  void setContent(String content) {
        this.content = content;
    }

    public static void main(String[] args) {
        ThreadLocalTest test = new ThreadLocalTest();

        for (int i = 0; i < 5; i++) {
            new Thread(() -> {
                synchronized (test) {
                    test.setContent(Thread.currentThread().getName() + "的数据");
                    System.out.println("-----------------------");
                    System.out.println(Thread.currentThread().getName() + "--->" + test.getContent());
                }
            }, "线程" + i).start();

        }
    }
}
